config: add default value for dhcpv6_pd_min_len
authorDavid Härdeman <[email protected]>
Sun, 14 Dec 2025 12:17:06 +0000 (13:17 +0100)
committerÁlvaro Fernández Rojas <[email protected]>
Sun, 14 Dec 2025 19:35:08 +0000 (20:35 +0100)
Right now, dhcpv6_pd_min_len is zero, meaning any request would be
accepted (as long as it fits what we have available).

That means that with a /56 (a common residential scenario), a downstream
router can request a /57 and gobble up 1/2 of the available address
space. Even a default dhcpv6_pd_min_len value of 60 means that we'd
support 15 PDs in total.

So let's err on the side of caution and set /62 as the default, people
who want larger allocations can easily override the default.

Signed-off-by: David Härdeman <[email protected]>
Link: https://github.com/openwrt/odhcpd/pull/357
Signed-off-by: Álvaro Fernández Rojas <[email protected]>
README.md
src/config.c

index 97717d27b3a953cb2057b53fc0676bb1070dcdd5..7226e526b9011a3ede5e5ebfd278ef2d8465c775 100644 (file)
--- a/README.md
+++ b/README.md
@@ -89,7 +89,7 @@ and may also receive information from ubus
 | dhcpv6_na            |bool   | 1     | DHCPv6 stateful addressing hands out IA_NA - Internet Address - Network Address |
 | dhcpv6_pd            |bool   | 1     | DHCPv6 stateful addressing hands out IA_PD - Internet Address - Prefix Delegation (PD) |
 | dhcpv6_pd_preferred   |bool | 0 | Set the DHCPv6-PD Preferred (P) flag in outgoing ICMPv6 RA message PIOs (RFC9762); requires `dhcpv6` and `dhcpv6_pd`. |
-| dhcpv6_pd_min_len    |integer| -     | Minimum prefix length to delegate with IA_PD (value is adjusted if needed to be greater than the interface prefix length).  Range [1,64] |
+| dhcpv6_pd_min_len    |integer| 62    | Minimum prefix length to delegate with IA_PD (adjusted, if necessary, to be longer than the interface prefix length).  Range [1,64] |
 | router               |list   |`<local address>`| IPv4 addresses of routers on a given subnet (provided via DHCPv4, should be in order of preference) |
 | dns                  |list   |`<local address>`| DNS servers to announce, accepts IPv4 and IPv6 |
 | dnr                  |list   |disabled| Encrypted DNS servers to announce, `<priority> <domain name> [<comma separated IP addresses> <SvcParams (key=value)>...]` |
index 6948b0fb236b40ef46a66dd79f4bc536a8471878..ca0b868002fb1b8ce3437a601212bf72de0fbb93 100644 (file)
@@ -69,7 +69,8 @@ struct sys_conf sys_conf = {
 #define HOSTID_LEN_MAX 64
 #define HOSTID_LEN_DEFAULT HOSTID_LEN_MIN
 
-#define PD_MIN_LEN_MAX 64
+#define PD_MIN_LEN_MAX         64
+#define PD_MIN_LEN_DEFAULT     62
 
 #define OAF_DHCPV6     (OAF_DHCPV6_NA | OAF_DHCPV6_PD)
 
@@ -324,7 +325,7 @@ static void set_interface_defaults(struct interface *iface)
        iface->dhcpv6_assignall = true;
        iface->dhcpv6_pd = true;
        iface->dhcpv6_pd_preferred = false;
-       iface->dhcpv6_pd_min_len = 0;
+       iface->dhcpv6_pd_min_len = PD_MIN_LEN_DEFAULT;
        iface->dhcpv6_na = true;
        iface->dhcpv6_hostid_len = HOSTID_LEN_DEFAULT;
        iface->dns_service = true;